
import log from '@/components/common/log'
import fixedbutton from '@/components/common/fixedbutton'
import download from '@/components/common/download'

import {getWinDetailsByProcInfo,findFileList,getWinDetailsById} from '@/api/api.js'


export default {
  components:{
    log,
    fixedbutton,
    download
  },
  data(){
    return {
      brand:[
      ],
      hasIcon:false,
      showFileBrand:false,
      procInstId:this.$route.params.task_id,
      flowLog:[],
      dataList:[],
      fileProps:[
        {prop:'fileRealName',label:'文件名'},
        {prop:'createTime',label:'上传时间'},
      ],
      isOpen1:'1',
      isOpen3:'1',
      win:{}
    }
  },
  methods: {
    getWinDetails: function(){
      let _this = this;
      let id = this.$route.query.obj.procGuid;
      //默认的fromNO为1  原来是通过procGuid来完成的  现在用fromNO 保存业务ID
      if(this.$route.query.obj.fromNO != "1"){
        getWinDetailsById(this.$route.query.obj.fromNO).then((result) => {
          if(result.status == "200"){
            _this.win = result.data.data;  
            if(_this.win.cudBonusProperty != null){
              _this.win.cudBonusProperty = _this.win.cudBonusProperty.split(',');
            }
            _this.getFileList(_this.win.cudWinId);
          }
        }).catch((err) => {
          _this.$alert(err,_this.$t('cm.tips'));
        });
      }else{
        //匹配原来的旧数据
        getWinDetailsByProcInfo(id).then((result) => {
          if(result.status == "200"){
            _this.win = result.data.data;  
            _this.getFileList(_this.win.cudWinId);
          }
        }).catch((err) => {
          _this.$alert(err,_this.$t('cm.tips'));
        });
      }
      
    },
    back:function(){
      this.$router.back();
    },
    getFileList:function(winId){
      let _this = this;
      findFileList({winId:winId}).then((result) => {
          if(result.status == "200" && result.data.code =="0"){
              _this.dataList = result.data.data;
          }else{
              _this.$alert(result.data.msg,_this.$t('cm.tips'));
          }
      }).catch((err) => {
          _this.$alert(err,_this.$t('cm.tips'));
      });
    }
  },
  mounted() {
    this.getWinDetails();
    this.procInstId = this.$route.params.task_id; 
    
  },
}
